<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>transite</title>


    <script src="GetOnlyFlag.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script type="text/javascript">
        var check = function (targetId) {
            //设备号
            var logflag = crc.get();
            //浏览器信息
            var userAgent = navigator.userAgent;
//            //IP地址
//            var cips = returnCitySN.cip;
            //地区
//            var cname = returnCitySN.cname;
            //客户端模式
            var mode = 'web';

            var sUserAgent = navigator.userAgent.toLowerCase();
            var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
            var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
            var bIsMidp = sUserAgent.match(/midp/i) == "midp";
            var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
            var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
            var bIsAndroid = sUserAgent.match(/android/i) == "android";
            var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
            var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
            if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
                mode = 'wap';
            }
            console.log(logflag);
            console.log(userAgent);
//            console.log(cips);
//            console.log(cname);
            console.log(mode);

            $.ajax({
                url: 'http://120.24.67.105:8383/visitHistory/insertVisitHistory',
                type: 'post',
                data: {
                    "productId": targetId,
                    "requestId": logflag,
                    "requestIp": '',
                    "requestUrl": 'http://www.jrstreet.cn/webLink/transit.html?targetId=' + targetId,
                    "requestMode": mode,
                    "requestLocation": '',
                    "requestUserAgent": userAgent,
                },
                async: true,
                success: function () {
                    console.log('success');
                },
                error: function (e) {
                    console.log(e);
                }
            });
        };
    </script>
    <script type="text/javascript">
        var targetId = getUrlParam('targetId=');

        function getUrlParam(name) {
            var r = window.location.href.split(name)[1];
            if (r != null) {
                return r;
            } else {
                return null;
            }
        }

        check(targetId);
        getData(targetId);

        var xhr;
        productlink = ''

        function getData(targetId) {
            if (!targetId) {
                console.log('kong')
                return;
            }

            $.ajax({
                url: 'http://120.24.67.105:8383/weblink/findWeblinkByGiud',
                type: 'post',
                data: {
                    "guid": targetId
                },
                async: true,
                success: function (obj) {
                    if (obj == '此链接不存在' || obj == '此链接已关闭') {
//                        document.getElementById("controller").innerText = "此链接已关闭";
                        document.getElementById("controller").style.display = "block";
                        document.getElementById("content").style.display = "none";
                    } else {
                        productlink = obj;
//                        document.getElementById("controller").innerHTML = '<a href="' + obj + '">' + obj + '</a>';
                        document.getElementById("controller").style.display = "none";
                        document.getElementById("content").style.display = "block";
                        //window.location.replace(obj)
                    }
                },
                error: function (e) {
                    console.log(e);
                }
            });
        }

        var submitform = function () {
            //IP地址
            var cips = returnCitySN.cip;
            console.log(cips);
            //验证表单
//            var name = document.getElementById("firstname").value;
            var telephone = document.getElementById("lastname").value;
            if (telephone == '' || telephone == undefined) {
                alert('请输入正确的电话')
            } else if (!(/^1(3|4|5|7|8)\d{9}$/.test(telephone))) {
                alert("手机号码有误，请重填");
            } else {
                $.ajax({
                    url: 'http://120.24.67.105:8383/registerHistory/insert',
                    type: 'post',
                    data: {
                        "productId": targetId,
                        "name": '',
                        "telephone": telephone,
                        "ip": cips
                    },
                    async: true,
                    success: function (obj) {
                        console.log(obj);
                        if(obj=='yes') {
                            window.location.replace(productlink);
                        }
                        else {
                            alert("您已申请过，无法重复申请");
                        }
                    },
                    error: function (e) {
                        console.log(e);
                    }
                });
            }

        }
    </script>
</head>
<body style="text-align: center;font-size: 50px">
<div  style="margin-top: 300px;font-size: 30px;color: #ff7277">该提交仅用于登记，非有效注册，提交后请继续完善后续注册和申请</div>
<div id="content" class="" style="margin-top: 45px;">
    <!--<div class="row">-->
        <!--<div class="col-xs-2 col-sm-2"></div>-->
        <!--<div class="col-xs-2 col-sm-2">姓名</div>-->
        <!--<div class="col-xs-6 col-sm-6">-->
            <!--<input type="text" id="firstname"-->
                   <!--placeholder="请输入姓名">-->

        <!--</div>-->
        <!--<div class="col-xs-2 col-sm-2"></div>-->
    <!--</div>-->
    <div class="row" style="margin-top: 45px">
        <div class="col-xs-2 col-sm-2"></div>
        <!--<div class="col-xs-2 col-sm-2">手机</div>-->
        <div class="col-xs-8 col-sm-8">
            <input type="text" id="lastname" style="border:0.5px solid #000"
                   placeholder="请输入手机号码">

        </div>

    </div>
    <div class="row" style="margin-top: 45px">
        <div class="col-xs-2 col-sm-2"></div>
        <div class="col-xs-8 col-sm-8">
            <button class="btn btn-default btn-lg" style="font-size: 55px;border:0.5px solid #000" onclick="submitform()">提交登记</button>
        </div>
        <div class="col-xs-2 col-sm-2"></div>

    </div>
</div>
</div>
<div id="controller" style="margin-top: 400px;display: none">此链接已关闭</div>
</body>
</html>